﻿using DAO;
using DBQLTV;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BUS
{
    public class DocGiaBUS
    {
        DocGiaDAO _DocGiaDAO = new DocGiaDAO();
        public bool InsertDocGia(string HoTen, string DiaChi, string TenLoaiDocGia, string NgaySinh, string Email, string NgayLapThe, string NgayHetHanThe)
        {
            if (LoaiDocGiaDAO.GetLoaiDocGiaByName(TenLoaiDocGia) != null)
            {
                return _DocGiaDAO.InsertDocGia(HoTen, DiaChi, LoaiDocGiaDAO.GetLoaiDocGiaByName(TenLoaiDocGia), Email, NgaySinh, NgayLapThe, NgayHetHanThe);
            }
            return false;
        }
        public bool UpdateTongNo(int MaDocGia, int TongNo)
        {
            return _DocGiaDAO.UpdateTongNo(MaDocGia, TongNo);
        }
        public bool DeleteDocGia(int MaDocGia)
        {
            return _DocGiaDAO.DeleteDocGia(MaDocGia);
        }
        public DOCGIA GetDocGia(string HoTen, string NgaySinh, string DiaChi)
        {
            return _DocGiaDAO.GetDocGia(HoTen, NgaySinh, DiaChi);
        }
        public DOCGIA GetDocGia(int MaDG)
        {
            return _DocGiaDAO.GetDocGia(MaDG);
        }
        public List<DOCGIA> GetListDocGia()
        {
            return _DocGiaDAO.GetListDocGia();
        }
        public List<int> GetListMaDocGiaByName(string HoTen)
        {
            return _DocGiaDAO.GetListMaDocGiaByName(HoTen);
        }
        public int GetSoLuongCuonSachDangMuon(int MaDG)
        {
            CuonSachBUS cuonsachBUS = new CuonSachBUS();
            List<int> list = cuonsachBUS.GetListMaCuonSachMuonBoiDocGia(MaDG);
            return list.Count();
        }
        public LOAIDOCGIA GetLoaiDocGia(int MaDG)
        {
            return _DocGiaDAO.GetLoaiDocGia(MaDG);
        }
    }
}
